/**
 * CellRender.java 2008-05-16
 * 
 * Linker is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

package linker.list;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

/**
 * The item's CellRender which is displayed in the list. The unit to show the
 * list.
 * 
 * @version 2008-05-16
 * @author AwakenRz awakenrz@gmail.com
 * 
 */

public class CellRender extends DefaultListCellRenderer {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Set cellRender.
	 * 
	 * @param list
	 *            The JList which use this cell render.
	 * @param value
	 *            The current object in the list.
	 * @param index
	 *            The index of the current object in the list.
	 * @param iss
	 *            Iss
	 * 
	 * @param chf
	 *            Chf
	 * 
	 * @return The current object to be showed in the list.
	 */
	public final Component getListCellRendererComponent(final JList list,
			final Object value, final int index, final boolean iss,
			final boolean chf) {
		super.getListCellRendererComponent(list, value, index, iss, chf);

		ListItem item = (ListItem) value;

		setIcon(item.getIcon());
		setToolTipText(item.getTipText());
		setText(item.getTitle());

		return this;
	}
}
